from enum import Enum


class CustomException(Exception):
    """自定义异常类"""
    def __init__(self, code: int, message: str):
        self.code = code
        self.message = message


class ResponseExceptionEnum(Enum):
    """定义response错误码
    """
    SUCCESS = (0, "请求成功")
    SYSTEM_ERROR = (1000, "系统错误")
    PARAMETER_ERROR = (1001, "参数错误")
    API_CALL_ERROR = (1002, "API调用错误")
    MODEL_NOT_SUPPORT = (1003, "模型不支持")

    def __init__(self, code, message):
        self.code = code
        self.message = message

    def __new__(cls, code, message):
        obj = object.__new__(cls)
        obj.code = code
        obj.message = message
        return obj

    def modify_message(self, new_message: str) -> None:
        """动态修改错误消息"""
        self.message = new_message

